﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Trace.Read_WebApi.Commands;

namespace Trace.Read_WebApi.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ReadTraceController : ControllerBase
    {
        private readonly IMediator _mediator;

        public ReadTraceController(IMediator mediator)
        {
            _mediator = mediator;
        }

        /// <summary>
        /// 获取货主合同跟踪列表
        /// </summary>
        /// <param name="listHZTraceCommands"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> ListHZTraceAsync([FromQuery]ListHZTraceCommands listHZTraceCommands)
        {
            return Ok(await _mediator.Send(listHZTraceCommands));
        }

        /// <summary>
        /// 获取承运合同跟踪列表
        /// </summary>
        /// <param name="listCYTraceCommands"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> ListCYTraceAsync([FromQuery] ListCYTraceCommands listCYTraceCommands)
        {
            return Ok(await _mediator.Send(listCYTraceCommands));
        }

        /// <summary>
        /// 获取货主合同跟踪记录
        /// </summary>
        /// <param name="tailShowHZTraceCommand"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> TailShowHZTraceAsync([FromQuery]TailShowHZTraceCommand tailShowHZTraceCommand)
        {
            return Ok(await _mediator.Send(tailShowHZTraceCommand));
        }

        /// <summary>
        /// 获取承运合同跟踪记录
        /// </summary>
        /// <param name="tailShowCYTraceCommand"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> TailShowCYTraceAsync([FromQuery] TailShowCYTraceCommands tailShowCYTraceCommand)
        {
            return Ok(await _mediator.Send(tailShowCYTraceCommand));
        }

        /// <summary>
        /// 获取车辆经纬度
        /// </summary>
        /// <param name="getLocationCommands"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> GetLocationAsync([FromQuery] GetLocationCommands getLocationCommands)
        {
            return Ok(await _mediator.Send(getLocationCommands));
        }

        /// <summary>
        /// 获取跟踪记录
        /// </summary>
        /// <param name="getTailCommands"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> GetTailAsync([FromQuery]GetTailCommands getTailCommands)
        {
            return Ok(await _mediator.Send(getTailCommands));
        }
    }
}
